<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;

?>
<div class="main" style="padding-top:10px;">
<div class="hide"><iframe name='send_post' id='send_post'></iframe></div>

    <div id="myTabContent" class="tab-content">

            <form class="" action="<?=Url::toRoute(['financial/cashier'])?>" method="get">
			  <div class="lh45">
			    <input type="text" class="lh45" placeholder="输入会员姓名" name='name' style="width:200px;float:left; margin-left:15px;" value="<?=$name?>" id="exampleInputName2" >
			    <input type="hidden" name="action" value="getUserlist" />
                <span class="btnBg ml20">
						<input type="submit" value="搜索" style="display: inline-block; width: 100%; background: 0;line-height: 25px; border: 0"  />
                </span>
			  </div>
			</form>
            <div class="clearfix"></div>
            <div style="margin-top:20px;"></div>

                <div class="">
                    <table class="table table-bordered userlist" style="table-layout: fixed;">
                        <thead>
                        <tr>
                            <th>会员</th>
                            <th>电话</th>
                            <th>会员类型</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                        	<td class="text-center" colspan='4'><p style="font-size:16px; cursor:pointer;" class="add" dtitle="新会员资料" durl="<?=Url::toRoute(['financial/cashier','action'=>'adduser'])?>">
                                <img class="mr10" src="<?=Yii::getAlias('@web/backend/img/financial/addnew.png');?>" alt=""/>添加新客</p></td>
                        </tr>
                        <?php foreach ($list as $r):?>
                        <tr idVal="<?=$r['member_id']?>" style="cursor: pointer;">
                        	<?php ActiveForm::begin([
                        		'options'=>['target'=>'send_post'],
                        		'action'=>Url::toRoute(['financial/cashier','action'=>'updateuserinfo'])
							]);?>
                        	<td><input class="read-only" type="text" value="<?=$r['member_name']?>" name="name" readonly/>
                                <input type="hidden" name="id" value="<?=$r['member_id']?>" readonly/></td>
                        	<td><input class="read-only" type="text" value="<?=$r['member_mobile']?>" name="mobile" readonly/></td>
                        	<td>
                                <div class="select hidden hideBox" style="width: 130px;">
                        	<select name="grade">
                        		<option>无</option>
                        		<?php foreach ($card_list as $v):?>
                        		<option value="<?=$v['config_key']?>" <?php if($v['config_key'] == $r['member_grade']):?> selected="selected" <?php endif;?>><?=$v['config_key']?></option>
                        		<?php endforeach;?>
                        	</select>
                                </div>
                        	 <input class="showBox read-only" type="text" value="<?=$r['member_grade']?$r['member_grade']:'无'?>" name="grade" readonly/>
                        	</td>
                        	<td><!--<a href="javascript:void(0);" onclick="parent.select_user(<?=$r['member_id']?>)" class="del btn btn-sm btn-borB4">选择</a>-->
                                <a class="del editBtn btn btn-sm btn-borB4" href="javascript:;">编辑</a>
                        		<div class="fadeBox" style="display: none">
                                	<input type="submit" class="btn btn-sm btn-borB" onclick="return checkCashier()" value="保存"/>
                                    <a href="javascript:;" class="rest btn btn-sm btn-borB1">取消</a>
                                </div></td>
                        	<?php ActiveForm::end();?>
                        </tr>
                        <?php endforeach;?>
                        </tbody>
                    </table>
                </div>
                <div class="page" style="text-align:center;">
                   <?=LinkPager::widget([
					    'pagination' => $page,
						'firstPageLabel' => '首页',
						'nextPageLabel' => '下一页',
						'prevPageLabel' => '上一页',
						'lastPageLabel' => '末页',
					    'hideOnSinglePage'=>false
					]); ?>
                </div>

        </div>


</div>


<?php $this->beginBlock('js_index_end') ?>
var posturl = '<?=Url::toRoute(['financial/cashier','action'=>'adduser']) ?>';
var csrf = '<?=Yii::$app->getRequest()->getCsrfToken()?>'
// 会员名字段验证
    function checkCashier(){
    var $username = document.getElementsByName('name')
    for (var i=0;i<$username.length;i++) {
        var $cash = $username[i]
            if($cash.value!=''&& $cash.value.length >5 ){
                layer.alert('会员名称不能超过5个字', {
                    icon: 2,
                });
                return false;
            };
      };
    }




<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index_end'], $this::POS_END); ?>

<?php $this->registerJsFile("@web/system/financial/cashier/userlist.js",['position'=>$this::POS_END]);?>
